<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增四闲场所信息')"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-places-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">地址编码：</label>
            <div class="col-sm-8">
                <input name="dzbm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">地址名称：</label>
            <div class="col-sm-8">
                <input name="dzmc" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房主姓名：</label>
            <div class="col-sm-8">
                <input name="fzXm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房主公民身份号码：</label>
            <div class="col-sm-8">
                <input name="fzGmsfhm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房主联系电话：</label>
            <div class="col-sm-8">
                <input name="fzLxdh" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">使用形式：</label>
            <div class="col-sm-8">
                <select name="syxs" class="form-control m-b" th:with="type=${@dict.getParamValue('SQJW_SYXS')}">
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">房屋类别：</label>
            <div class="col-sm-8">
                <select name="fwlbdm" class="form-control m-b" th:with="type=${@dict.getParamValue('SQJW_FWLB')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">房屋用途：</label>
            <div class="col-sm-8">
                <select name="fwytdm" class="form-control m-b" th:with="type=${@dict.getParamValue('SQJW_FWYT')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房屋管理级别：</label>
            <div class="col-sm-8">
                <input name="fwgljb" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">房屋性质：</label>
            <div class="col-sm-8">
                <select name="fwcqxzzldm" class="form-control m-b" th:with="type=${@dict.getParamValue('SQJW_FWXZ')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房屋面积：</label>
            <div class="col-sm-8">
                <input name="fwmjMjpfm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房屋间数：</label>
            <div class="col-sm-8">
                <input name="fwjs" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">房屋是否托管：</label>
            <div class="col-sm-8">
                <select  name="fwtg"  class="form-control m-b"
                        th:with="type=${@dict.getParamValue('SFZD_DQJC')}">
                    <option th:each="dict : ${type}"
                            th:text="${dict.itemText}"
                            th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属派出所：</label>
            <div class="col-sm-8">
                <input name="sspcs" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属民警账号：</label>
            <div class="col-sm-8">
                <input name="ssmjZh" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属民警姓名：</label>
            <div class="col-sm-8">
                <input name="ssmjXm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属网格：</label>
            <div class="col-sm-8">
                <input name="sssqjwwgDzbm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">网格员姓名：</label>
            <div class="col-sm-8">
                <input name="wgyXm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">管区负责人姓名：</label>
            <div class="col-sm-8">
                <input name="gqfzrXm" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">社区（村）居委会：</label>
            <div class="col-sm-8">
                <input name="sqjwh" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">建筑名称：</label>
            <div class="col-sm-8">
                <input name="jzmc" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">门牌号：</label>
            <div class="col-sm-8">
                <input name="mph" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址位置：</label>
            <div class="col-sm-8">
                <input name="dzwz" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址是否存在：</label>
            <div class="col-sm-8">
                <select  name="dzsfcz"  class="form-control m-b"
                         th:with="type=${@dict.getParamValue('SFZD_DQJC')}">
                    <option th:each="dict : ${type}"
                            th:text="${dict.itemText}"
                            th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址是否在用：</label>
            <div class="col-sm-8">
                <select  name="dzsfzy"  class="form-control m-b"
                         th:with="type=${@dict.getParamValue('SFZD_DQJC')}">
                    <option th:each="dict : ${type}"
                            th:text="${dict.itemText}"
                            th:value="${dict.itemValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">图片：</label>
            <div class="col-sm-8 fileinput fileinput-new" data-provides="fileinput" style="text-align: center; margin-bottom: 0;">
                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px; margin-right: 10px;"></div>
                <span class="btn btn-white btn-file">
                    <span class="fileinput-new">选择图片</span>
                    <span class="fileinput-exists">更改</span>
                    <input name="photo" type="hidden" value="">
                    <input id="williamYe" type="file">
                </span>
                <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: jasny-bootstrap-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "control/places"

    $("#form-places-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            save(prefix + "/add", $('#form-places-add').serialize(), function (res) {
                if(res.success){
                    $.modal.close();
                    parent.closeNowTab();
                    window.parent.$.modal.openTab("四闲场所", $.common.setURL("/control/places"));
                }
            });
        }
    }

    function save(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function (request) {
                request.setRequestHeader("X-Access-Token", storage.get("token"));
            },
            success: function(result) {
                callback(result);
            }
        };
        $.ajax(config)
    }

    $('#williamYe').on('change.bs.fileinput ', function (e) {
            // 处理自己的业务
            if(this.files[0]){
                const formData = new FormData();
                formData.append('file',this.files[0]);
                $.operate.fileUpload(formData, $('input[name="photo"]'));
            }else{
                $('input[name="photo"]').val("");
            }
        });
</script>
</body>
</html>
